package com.gxa.uhome.service.impl;

import com.gxa.uhome.exception.BusinessException;
import com.gxa.uhome.mapper.UODSVoMapper;
import com.gxa.uhome.pojo.vo.UODSVo;
import com.gxa.uhome.service.UODSVoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * User: Sanruy Mu
 * Date: 2021/06/08 18:16
 * Description:
 * Version: V1.0
 */
@Service("uODSService")
public class UODSVoServiceImpl implements UODSVoService {
    @Resource
    UODSVoMapper uodsVoMapper;

    @Override
    public List<UODSVo> selectAll() throws BusinessException {
        List<UODSVo> uodsVos = uodsVoMapper.selectAll();
        if(uodsVos!=null){
            return uodsVos;
        }else{
            throw new BusinessException("未查询到信息，请稍后再试");
        }
    }

    @Override
    public List<UODSVo> selectByUserIdAndPage(Integer id,Integer page) throws BusinessException {
        page = (page-1)*8;
        List<UODSVo> uodsVos = uodsVoMapper.selectByUserIdAndPage(id,page);
        if(uodsVos!=null){
            return uodsVos;
        }else{
            throw new BusinessException("无订单信息");
        }
    }
}